import { Close } from "@mui/icons-material";
import { IconButton, Snackbar } from "@mui/material";

export type ToastProps = {
  open: boolean;
  onClose: () => void;
  message: string;
  duration?: number;
};

export default function Toast({ open, onClose, message, duration = 3000 }: ToastProps) {
  const action = (
    <IconButton size="small" aria-label="close" color="inherit" onClick={onClose}>
      <Close fontSize="small" />
    </IconButton>
  );

  return (
    <Snackbar
      anchorOrigin={{ vertical: "top", horizontal: "center" }}
      open={open}
      autoHideDuration={duration}
      onClose={onClose}
      message={message}
      action={action}
    />
  );
}
